package cn.tedu.io;

import java.io.*;

//测试  字节读取流
public class Test3_InputStream {
    public static void main(String[] args)  {
        method();
        method2();
    }
    public static void method()  {
        InputStream in = null;
        InputStream in2 = null;
        try {
            in = new FileInputStream(
                    "D:\\iotest\\1.txt");
            in2 = new FileInputStream(
                    new File("D:\\iotest\\1.txt"));

            int b = 0;
            while ((b = in.read()) != -1 ){
                System.out.println((char) b);
            }
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            try {
                in.close();
                in2.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    public static void method2()  {
        InputStream in = null;
        try {
            in = new BufferedInputStream(
                    new FileInputStream("D:\\iotest\\1.txt"));
            int b = 0;
            while ((b = in.read()) != -1){
                System.out.println(b);
            }
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
